package com.yunxi.service.localService.vehicle.impl;

import com.codingapi.txlcn.tc.annotation.LcnTransaction;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yunxi.core.service.ServiceImplPlus;
import com.yunxi.dao.vehicle.VehiclePackageMapper;
import com.yunxi.model.vehicle.VehiclePackage;
import com.yunxi.model.vehicle.VehiclePackageCustomer;
import com.yunxi.service.localService.vehicle.VehiclePackageService;
import com.yunxi.vehicle.pojo.VehiclePackageConfigForAppRespVO;
import com.yunxi.vehicle.pojo.VehiclePackageForAppReqVO;
import com.yunxi.vehicle.pojo.VehiclePackageForAppRespVO;
import com.yunxi.vehicle.pojo.VehiclePackageRespVO;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 
 * @since 2019-05-22
 */
@Service(value = "vehiclePackageServiceImpl")
public class VehiclePackageServiceImpl extends ServiceImplPlus<VehiclePackageMapper,VehiclePackage> implements VehiclePackageService {

    @Override
    public List<VehiclePackageCustomer> queryVehiclePackage(String productCode) {
        return this.baseMapper.queryVehiclePackage(productCode);
    }

    @Override
    public List<VehiclePackageForAppRespVO> queryVehiclePackageByApp(VehiclePackageForAppReqVO vo){
        return this.baseMapper.queryVehiclePackageByApp(vo);
    }

    @Override
    public List<VehiclePackageForAppRespVO> queryVehiclePackageByAppLast(VehiclePackageForAppReqVO vo){
        return this.baseMapper.queryVehiclePackageByAppLast(vo);
    }

    @Override
    public PageInfo<VehiclePackageConfigForAppRespVO> queryVehiclePackageConfigByApp(int pageNum, int pageSize){
        PageHelper.startPage(pageNum,pageSize);
        List<VehiclePackageConfigForAppRespVO> result = this.baseMapper.queryVehiclePackageConfigByApp();
        return new PageInfo<>(result);
    }

    @Override
    @Transactional
    @LcnTransaction
    public List<VehiclePackageForAppRespVO> queryTest() {
        return baseMapper.queryTest();
    }

    @Override
    public String strByNodeCodeIn(String customSqlStr) {
        if(StringUtils.isNotEmpty(customSqlStr)){
            VehiclePackageForAppRespVO vo = baseMapper.strByNodeCodeIn(customSqlStr);
            if(vo!=null&&vo.getCustomSqlStr()!=null)
                return vo.getCustomSqlStr();
        }
        return "";
    }


}
